#pragma once

#include "TypeInfo.h"
#include "Helpers.h"

namespace MockItNow
{
	class ReturnValueRecordInterface
	{
	public:

		virtual ~ReturnValueRecordInterface()
		{
		}

		virtual std::string GetTypeName() const = 0;
	};

	template<typename T>
	class ReturnValueRecord : public ReturnValueRecordInterface
	{
	public:
	
		typedef typename TypeInfo<T>::StorageType ReturnValueType;

		ReturnValueRecord()
		: m_returnValue(0)
		{
		}

		virtual ~ReturnValueRecord()
		{
			delete m_returnValue;
		}

		virtual std::string GetTypeName() const
		{
			return GetFriendlyTypeName<T>();
		}

		void SetReturnValue(ReturnValueType const & returnValue)
		{
			m_returnValue = new ReturnValueType(returnValue);
		}
	
		ReturnValueType& GetReturnValue() const
		{
			MOCKITNOW_ASSERT(m_returnValue != 0);
			return *m_returnValue;
		}

	private:

		ReturnValueType* m_returnValue;
	};
}
